/**
 * 
 */
package org.easybuy.daoimpol;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.easybuy.dao.BaseDao;
import org.easybuy.dao.ProductDao;
import org.easybuy.entity.Product;

/**
 * 
 * @商品实现类
 *
 */
public class ProductDaoImpol extends BaseDao implements ProductDao {
	//根据三级标题查找商品
	@Override
	public List<Product> getAllProductBy3Id(int ID3) {
		ResultSet rs = null;
		String sql = "SELECT *FROM `easybuy_product` WHERE categoryLevel3Id = ?";
		List<Product> list = new ArrayList<Product>();
		Product product = null;
		rs = this.exxcuteQuery(sql, ID3);
		try {
			while (rs.next()) {
				product = new Product();
				product.setId(rs.getInt("id"));
				product.setName(rs.getString("name").toString());
				product.setDescription(rs.getString("description").toString());
				product.setPrice(rs.getString("price").toString());
				product.setStock(rs.getString("stock").toString());
				product.setCategoryLevel1Id(rs.getInt("categoryLevel1Id"));
				product.setCategoryLevel2Id(rs.getInt("categoryLevel2Id"));
				product.setCategoryLevel3Id(rs.getInt("categoryLevel3Id"));
				product.setFileName(rs.getString("fileName").toString());
				product.setIsDelete(rs.getInt("isDelete"));
				list.add(product);
				
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			BaseDao.closeAll(connection, pstmt, rs);
		}
		return list;
	}

}
